<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('db limit list')" />
	<th:block th:include="include :: layout-latest-css" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="form">
					<input type="hidden" id="pageFlag" name="pageFlag" th:value="${dbLimit.pageFlag}"/>
					<div class="select-list">
						<ul>
							<li>
								考核组：
								<select name="khz" id="khz" th:with="dicts=${@dict.getType('rate_khz')}">
									<option value="">--请选择--</option>
									<option th:each="dict : ${dicts}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
										th:selected="${dbLimit.khz == dict.dictValue}"></option>
								</select>
							</li>
							<li>
								考核单位：
								<select name="dept.deptId" id="dept.deptId">
									<option value="">--请选择--</option>
									<option th:each="dept : ${deptList}" th:text="${dept.deptName}" th:value="${dept.deptId}"
										th:selected="${dbLimit.dept.deptId == dept.deptId}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								
								<a style="margin-left:20px;" class="btn btn-danger btn-rounded btn-sm" onclick="add()">
									<i class="fa fa-plus"></i> 新增
								</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<script th:inline="javascript">
		var prefix = ctx + "rate/dbLimit";
		var khzDict = [[${@dict.getType('rate_khz')}]];
		var pageFlag = [[${dbLimit.pageFlag}]];

		$(function() {
			list();
		});

		function list() {
			var cols = [];
			cols.push({
				field: 'id',
				visible: false
			});
			cols.push({
				field: 'khz',
				align: 'center',
				title: '考核组',
				formatter: function(value, row, index) {
					return $.table.selectDictLabel(khzDict, value);
				}
			});
			cols.push({
				field: 'dept.deptName',
				align: 'center',
				title: '考核部门'
			});
			cols.push({
				field: 'dwgs',
				align: 'center',
				title: '应督办单位个数'
			});
			cols.push({
				field: 'kfUp',
				align: 'center',
				title: '扣分（上限值）'
			});
			cols.push({
				field: 'kfUpCount',
				align: 'center',
				title: '扣分（上限值）单位个数'
			});
			cols.push({
				field: 'kfDown',
				align: 'center',
				title: '扣分（下限值）'
			});
			cols.push({
				field: 'kfDownCount',
				align: 'center',
				title: '扣分（下限值）单位个数'
			});
			cols.push({
				title: '操作',
				align: 'center',
				width: '30%',
				formatter: function(value, row, index) {
					var actions = [];
					actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
					actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="remove1(\'' + row.id + '\')"><i class="fa fa-times"></i>删除</a> ');
					actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="view(\'' + row.id + '\')"><i class="fa fa-query"></i>查看</a> ');
					return actions.join('');
				}
			});
			
			var options = {
				url: prefix + "/list",
				modalName: "dbLimit",
				uniqueId: "id",
				pagination: false,
				columns: cols
			};
			$.table.init(options);
		}
		
		function add() {
			$.modal.open("新增",
					prefix + "/add?pageFlag=ADD");
		}
		function edit(id) {
			$.modal.open("修改",
					prefix + "/edit?id=" + id + "&pageFlag=EDIT");
		}
		function view(id) {
			$.modal.open("查看",
					prefix + "/edit?id=" + id + "&pageFlag=VIEW");
		}
		function remove1(id) {
			$.modal.confirm("确认要删除该条记录吗?", function() {
				var url = prefix + "/delete/" + id;
				var data = {"timestamp": new Date().getTime()};
				$.operate.submit(url, "post", "json", data);
			});
		}
	</script>
</body>
</html>